﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbDynBlockReferenceProperty : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbDynBlockReferenceProperty(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbDynBlockReferenceProperty_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbDynBlockReferenceProperty obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbDynBlockReferenceProperty()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbDynBlockReferenceProperty(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public OdDbDynBlockReferenceProperty Assign(OdDbDynBlockReferenceProperty other)
		{
			OdDbDynBlockReferenceProperty result = (OdDbDynBlockReferenceProperty)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbDynBlockReferenceProperty_Assign(this.swigCPtr, OdDbDynBlockReferenceProperty.getCPtr(other)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbObjectId blockId()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr cPtr = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_blockId(this.swigCPtr);
			OdDbObjectId result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject(new OdDbObjectId(cPtr, true));
				result = new OdDbObjectId(cPtr, false);
			}
			else
			{
				result = new OdDbObjectId(cPtr, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string propertyName()
		{
			string result = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_propertyName(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdResBuf.ValueType propertyType()
		{
			OdResBuf.ValueType result = (OdResBuf.ValueType)TD_DbPINVOKE.OdDbDynBlockReferenceProperty_propertyType(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool readOnly()
		{
			bool result = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_readOnly(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool show()
		{
			bool result = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_show(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool visibleInCurrentVisibilityState()
		{
			bool result = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_visibleInCurrentVisibilityState(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public string description()
		{
			string result = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_description(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbDynBlockReferenceProperty.UnitsType unitsType()
		{
			OdDbDynBlockReferenceProperty.UnitsType result = (OdDbDynBlockReferenceProperty.UnitsType)TD_DbPINVOKE.OdDbDynBlockReferenceProperty_unitsType(this.swigCPtr);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getAllowedValues(OdResBufArray allowedValues)
		{
			TD_DbPINVOKE.OdDbDynBlockReferenceProperty_getAllowedValues(this.swigCPtr, OdResBufArray.getCPtr(allowedValues));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdResBuf value()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_value(this.swigCPtr);
			OdResBuf result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdResBuf)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool setValue(OdResBuf value)
		{
			bool result = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_setValue(this.swigCPtr, OdResBuf.getCPtr(value));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdDbBlockParameter getParameter()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbDynBlockReferenceProperty_getParameter(this.swigCPtr);
			OdDbBlockParameter result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbBlockParameter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbBlockParameter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbBlockParameter)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getDescriptor(SWIGTYPE_p_unsigned_long parameterId, OdDbBlkParamPropertyDescriptor pDescriptor)
		{
			TD_DbPINVOKE.OdDbDynBlockReferenceProperty_getDescriptor(this.swigCPtr, SWIGTYPE_p_unsigned_long.getCPtr(parameterId), OdDbBlkParamPropertyDescriptor.getCPtr(pDescriptor));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		public enum UnitsType
		{
			kNoUnits,
			kAngular,
			kDistance,
			kArea
		}
	}
}
